package com.example.demo2.guard;

import com.example.demo2.define.CDEvents;
import com.example.demo2.define.CDStates;
import com.example.demo2.define.Variables;
import org.springframework.statemachine.ExtendedState;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.guard.Guard;

public class PlayGuard implements Guard<CDStates, CDEvents> {

    @Override
    public boolean evaluate(StateContext<CDStates, CDEvents> context) {
        ExtendedState extendedState = context.getExtendedState();
        boolean hasCD = extendedState.getVariables().get(Variables.CD) != null;
        System.out.println("守卫检查结果[hasCD]: " + hasCD);
        return hasCD;
    }
}
